<%@ page language="java" pageEncoding="UTF-8"%>
<%@include file="/pc/jsp/common/common.jsp"%>

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
    <style>
        body{
            width: 100%;
            height: 100%;
            background: transparent;
        }
    </style>
    <script src="mb/js/jquery.cookie.js"></script>
</head>
<body>

<div class="loginBlock of bcf w100 h100">
    <div class="logintittle of tc pr">
        登 陆 <span class="pa cursor" id="close-x">&times;</span>
    </div>
    <div class="of jz" style="width: 454px;">
        <input type="text" name="" id="tel" placeholder="手机号码" class="db jz br3" style="margin-top: 72px;"/>
        <p class="t2 cred f14"></p>
        <input type="password" name="" id="pwd" placeholder="密码" class="db br3"/>
        <p class="t2 cred f14"></p>
        <div class="clearfix of" style="margin-top: 86px;">
            <input type="button" value="登&nbsp;陆" name="" id="loginSub" class="cursor tc cf fl db btnBlue" onclick="Sub();"/>
            <span id="fpwd" class="fl f17 aht cursor" style="color: #1e83f3;margin-left: 30px;margin-top: 39px">忘记密码?</span>
        </div>
    </div>
</div><!--loginBlock-->
<div id="loadingfDiv" class="loadingfDiv pf w100 h100 db">
    <div class="w100 h100">
        <img src="pc/images/loading.gif" class="db jz" style="margin-top: 40%;">
    </div>
</div><!--loadinfDiv-->


<script>
	var myTel="";
    $(window).on("load", function() {
        $("#loginBtn", parent.document).click(function () {
            $("#loginIframeDiv", parent.document).slideDown();
            $(".theme-popover-mask", parent.document).fadeIn();

        })
        $("#close-x,#fpwd").click(function () {
            $("#loginIframeDiv", parent.document).slideUp();
            $(".theme-popover-mask", parent.document).fadeOut();

        })
        $("#fpwd").click(function () {
            $("#forgotPwdIframeDiv", parent.document).slideDown(1000);
            $(".theme-popover-mask", parent.document).fadeIn(1000);

        })
        
          if ($.cookie("telCookie") != undefined) {
			$("#tel").val( $.cookie("telCookie"));//写入cookie记录账号
			} 
			myTel=$.cookie("telCookie");
    });
    
    function callLogin()
    {
            $("#loginIframeDiv", parent.document).slideDown();
            $(".theme-popover-mask", parent.document).fadeIn();
    }

    function Sub() {
    

        var tel =$.trim($('#tel').val());
        var pwd = $.trim($('#pwd').val());
        if(tel== ""){
            $('#tel').next('p').text('你还未填写联系电话');
            return false;
        }else if (tel != ""&&!(/^((\d{3}-\d{8}|\d{4}-\d{7,8})|(1[3|5|7|8][0-9]{9}))$/.test(tel))) {
            $('#tel').next('p').text('手机号填写的格式不对，请正确填写');
            return false;
        }else{
         $('#tel').next('p').text('');
        }

        if(pwd== ""){
        
            $('#pwd').next('p').text('你还未填写密码');
            return false;
        }else {
            $('#pwd').next('p').text('');
        }
        
          if(tel!="" && myTel != tel){
            	myTel=tel;
            	$.cookie("telCookie", myTel, { expires: 10 , path: '/' }); // 存储一个带10天期限的 cookie,验证记住帐号
            }
 
        $.ajax({
            url: "LoginServlet ",
            data: JSON.stringify({m:60,mobile :tel,password:$.md5(pwd),platform:0}),
            type: 'post',
            dataType: 'json',
            contentType:"application/json;charset=utf-8",
            beforeSend: function () {
                $("#loadingfDiv").fadeIn();
            },
            success: function (data) {console.info(data);
	             if(data['state']==1){
		             layer.alert(data.info);
		             //parent.loginOut();
		             parent.location.reload();
	             }
					
				 else
				  	layer.alert(data.info);
            },
            error: function (data) {
                layer.alert(data.msg);
                return false;
            },
            complete: function () {
                $("#loadingfDiv").fadeOut();

                
            }
        });
        
        
    }
</script>
</body>
</html>